/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 * Description: 获取动态库中ibverbs接口函数的适配接口
 * Author: linzhiyang
 * Create: 2022-11-17
 */


#ifndef HCCL_SRC_DLIBVFUNCTION_H
#define HCCL_SRC_DLIBVFUNCTION_H

#include <functional>
#include <mutex>
#include <hccl/hccl_types.h>

#include "base.h"
#include "ascend_hal.h"

namespace hccl {
class DlIbvFunction {
public:
    virtual ~DlIbvFunction();
    static DlIbvFunction &GetInstance();
    HcclResult DlIbvFunctionInit();
    std::function<s32(struct ibv_comp_channel *channel, struct ibv_cq **cq,
        void **cq_context)> dlRcoeGetCqEvent = nullptr;
    std::function<void(struct ibv_cq *qp, unsigned int nevents)> dlRcoeAckCqEvent = nullptr;
    std::function<s32(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask,
        struct ibv_qp_init_attr *init_attr)> dlRcoeQueryQp = nullptr;
protected:
private:
    void *handle_;
    std::mutex handleMutex_;
    DlIbvFunction(const DlIbvFunction&);
    DlIbvFunction &operator=(const DlIbvFunction&);
    DlIbvFunction();
    HcclResult DlIbvFunctionApiInit();
};
}  // namespace hccl

#endif  // HCCL_SRC_DLIBVFUNCTION_H
